package org.example.springioc.DI;

import org.example.springioc.Repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class Controller3 {

    private UserRepository userRepository;

    @Autowired
    public void setUserRepository(UserRepository userRepository) {
        this.userRepository = userRepository;
    }

    public void say(){
        userRepository.doRepo();
        System.out.println("hello Controller3");
    }
}
/*          Setter方法注入
 当只有一个方法的时候，会默认执行，如果不只一个方法的话，默认不会执行*/
